<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Conversions (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Conversions (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Conversions (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="RTL.html" rel="up" title="RTL">
<link href="RTL-Declarations.html" rel="next" title="RTL Declarations">
<link href="Vector-Operations.html" rel="prev" title="Vector Operations">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en">
<div class="section-level-extent" id="Conversions">
<div class="nav-panel">
<p>
Next: <a href="RTL-Declarations.html" accesskey="n" rel="next">Declarations</a>, Previous: <a href="Vector-Operations.html" accesskey="p" rel="prev">Vector Operations</a>, Up: <a href="RTL.html" accesskey="u" rel="up">RTL Representation</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Conversions-1"><span>14.13 Conversions<a class="copiable-link" href="#Conversions-1"> &para;</a></span></h3>
<a class="index-entry-id" id="index-conversions"></a>
<a class="index-entry-id" id="index-machine-mode-conversions"></a>

<p>All conversions between machine modes must be represented by
explicit conversion operations.  For example, an expression
which is the sum of a byte and a full word cannot be written as
<code class="code">(plus:SI (reg:QI 34) (reg:SI 80))</code> because the <code class="code">plus</code>
operation requires two operands of the same machine mode.
Therefore, the byte-sized operand is enclosed in a conversion
operation, as in
</p>
<div class="example smallexample">
<pre class="example-preformatted">(plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80))
</pre></div>

<p>The conversion operation is not a mere placeholder, because there
may be more than one way of converting from a given starting mode
to the desired final mode.  The conversion operation code says how
to do it.
</p>
<p>For all conversion operations, <var class="var">x</var> must not be <code class="code">VOIDmode</code>
because the mode in which to do the conversion would not be known.
The conversion must either be done at compile-time or <var class="var">x</var>
must be placed into a register.
</p>
<dl class="table">
<dt><a id="index-sign_005fextend"></a><span><code class="code">(sign_extend:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-sign_005fextend"> &para;</a></span></dt>
<dd><p>Represents the result of sign-extending the value <var class="var">x</var>
to machine mode <var class="var">m</var>.  <var class="var">m</var> must be a fixed-point mode
and <var class="var">x</var> a fixed-point value of a mode narrower than <var class="var">m</var>.
</p>
</dd>
<dt><a id="index-zero_005fextend"></a><span><code class="code">(zero_extend:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-zero_005fextend"> &para;</a></span></dt>
<dd><p>Represents the result of zero-extending the value <var class="var">x</var>
to machine mode <var class="var">m</var>.  <var class="var">m</var> must be a fixed-point mode
and <var class="var">x</var> a fixed-point value of a mode narrower than <var class="var">m</var>.
</p>
</dd>
<dt><a id="index-float_005fextend"></a><span><code class="code">(float_extend:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-float_005fextend"> &para;</a></span></dt>
<dd><p>Represents the result of extending the value <var class="var">x</var>
to machine mode <var class="var">m</var>.  <var class="var">m</var> must be a floating point mode
and <var class="var">x</var> a floating point value of a mode narrower than <var class="var">m</var>.
</p>
</dd>
<dt><a id="index-truncate"></a><span><code class="code">(truncate:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-truncate"> &para;</a></span></dt>
<dd><p>Represents the result of truncating the value <var class="var">x</var>
to machine mode <var class="var">m</var>.  <var class="var">m</var> must be a fixed-point mode
and <var class="var">x</var> a fixed-point value of a mode wider than <var class="var">m</var>.
</p>
</dd>
<dt><a id="index-ss_005ftruncate"></a><span><code class="code">(ss_truncate:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-ss_005ftruncate"> &para;</a></span></dt>
<dd><p>Represents the result of truncating the value <var class="var">x</var>
to machine mode <var class="var">m</var>, using signed saturation in the case of
overflow.  Both <var class="var">m</var> and the mode of <var class="var">x</var> must be fixed-point
modes.
</p>
</dd>
<dt><a id="index-us_005ftruncate"></a><span><code class="code">(us_truncate:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-us_005ftruncate"> &para;</a></span></dt>
<dd><p>Represents the result of truncating the value <var class="var">x</var>
to machine mode <var class="var">m</var>, using unsigned saturation in the case of
overflow.  Both <var class="var">m</var> and the mode of <var class="var">x</var> must be fixed-point
modes.
</p>
</dd>
<dt><a id="index-float_005ftruncate"></a><span><code class="code">(float_truncate:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-float_005ftruncate"> &para;</a></span></dt>
<dd><p>Represents the result of truncating the value <var class="var">x</var>
to machine mode <var class="var">m</var>.  <var class="var">m</var> must be a floating point mode
and <var class="var">x</var> a floating point value of a mode wider than <var class="var">m</var>.
</p>
</dd>
<dt><a id="index-float"></a><span><code class="code">(float:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-float"> &para;</a></span></dt>
<dd><p>Represents the result of converting fixed point value <var class="var">x</var>,
regarded as signed, to floating point mode <var class="var">m</var>.
</p>
</dd>
<dt><a id="index-unsigned_005ffloat"></a><span><code class="code">(unsigned_float:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-unsigned_005ffloat"> &para;</a></span></dt>
<dd><p>Represents the result of converting fixed point value <var class="var">x</var>,
regarded as unsigned, to floating point mode <var class="var">m</var>.
</p>
</dd>
<dt><a id="index-fix"></a><span><code class="code">(fix:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-fix"> &para;</a></span></dt>
<dd><p>When <var class="var">m</var> is a floating-point mode, represents the result of
converting floating point value <var class="var">x</var> (valid for mode <var class="var">m</var>) to an
integer, still represented in floating point mode <var class="var">m</var>, by rounding
towards zero.
</p>
<p>When <var class="var">m</var> is a fixed-point mode, represents the result of
converting floating point value <var class="var">x</var> to mode <var class="var">m</var>, regarded as
signed.  How rounding is done is not specified, so this operation may
be used validly in compiling C code only for integer-valued operands.
</p>
</dd>
<dt><a id="index-unsigned_005ffix"></a><span><code class="code">(unsigned_fix:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-unsigned_005ffix"> &para;</a></span></dt>
<dd><p>Represents the result of converting floating point value <var class="var">x</var> to
fixed point mode <var class="var">m</var>, regarded as unsigned.  How rounding is done
is not specified.
</p>
</dd>
<dt><a id="index-fract_005fconvert"></a><span><code class="code">(fract_convert:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-fract_005fconvert"> &para;</a></span></dt>
<dd><p>Represents the result of converting fixed-point value <var class="var">x</var> to
fixed-point mode <var class="var">m</var>, signed integer value <var class="var">x</var> to
fixed-point mode <var class="var">m</var>, floating-point value <var class="var">x</var> to
fixed-point mode <var class="var">m</var>, fixed-point value <var class="var">x</var> to integer mode <var class="var">m</var>
regarded as signed, or fixed-point value <var class="var">x</var> to floating-point mode <var class="var">m</var>.
When overflows or underflows happen, the results are undefined.
</p>
</dd>
<dt><a id="index-sat_005ffract"></a><span><code class="code">(sat_fract:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-sat_005ffract"> &para;</a></span></dt>
<dd><p>Represents the result of converting fixed-point value <var class="var">x</var> to
fixed-point mode <var class="var">m</var>, signed integer value <var class="var">x</var> to
fixed-point mode <var class="var">m</var>, or floating-point value <var class="var">x</var> to
fixed-point mode <var class="var">m</var>.
When overflows or underflows happen, the results are saturated to the
maximum or the minimum.
</p>
</dd>
<dt><a id="index-unsigned_005ffract_005fconvert"></a><span><code class="code">(unsigned_fract_convert:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-unsigned_005ffract_005fconvert"> &para;</a></span></dt>
<dd><p>Represents the result of converting fixed-point value <var class="var">x</var> to
integer mode <var class="var">m</var> regarded as unsigned, or unsigned integer value <var class="var">x</var> to
fixed-point mode <var class="var">m</var>.
When overflows or underflows happen, the results are undefined.
</p>
</dd>
<dt><a id="index-unsigned_005fsat_005ffract"></a><span><code class="code">(unsigned_sat_fract:<var class="var">m</var> <var class="var">x</var>)</code><a class="copiable-link" href="#index-unsigned_005fsat_005ffract"> &para;</a></span></dt>
<dd><p>Represents the result of converting unsigned integer value <var class="var">x</var> to
fixed-point mode <var class="var">m</var>.
When overflows or underflows happen, the results are saturated to the
maximum or the minimum.
</p></dd>
</dl>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="RTL-Declarations.html">Declarations</a>, Previous: <a href="Vector-Operations.html">Vector Operations</a>, Up: <a href="RTL.html">RTL Representation</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
